package com.cloud.spring.demo.controller;

import com.cloud.spring.demo.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("email")
public class EmailController {
    @Autowired
    EmailService emailService;

    /**
     * 发送文本邮件
     *
     * @return
     */
    @RequestMapping("sendSimpleMail")
    public String sendSimpleMail() {
        emailService.sendSimpleMail();
        return "Success";
    }

    /**
     * 发送html邮件
     *
     * @return
     * @throws Exception
     */
    @RequestMapping("sendHtmlMail")
    public String sendHtmlMail() throws Exception {
        emailService.sendHtmlMail();
        return "Success";
    }

    /**
     * 发送带图片的html邮件
     *
     * @return
     * @throws Exception
     */
    @RequestMapping("sendAttachedImageMail")
    public String sendAttachedImageMail() throws Exception {
        emailService.sendAttachedImageMail();
        return "Success";
    }

    /**
     * 发送带附件的邮件
     *
     * @return
     * @throws Exception
     */
    @RequestMapping("sendAttendedFileMail")
    public String sendAttendedFileMail() throws Exception {
        emailService.sendAttendedFileMail();
        return "Success";
    }
}
